<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of NnwtmintPriceScraper
 *
 * @author thedaego
 */

class NnwtmintPriceScraper extends PriceScraper
{
    private $cell_landmark = "Price:";
    function getPrice($regex)
    {
        $page =  http_get($this->url, "");
        $table_array = parse_array($page['FILE'], "<table", "</table>");
        $product_row_array = null;
        $table_cell_array = null;
        $return_value = null;
        for($xx=0; $xx<count($table_array); $xx++)
        {
            $table_landmark = "B15005";
            if(stristr($table_array[$xx], $table_landmark))     // Process this table
            {
                if(stristr($table_array[$xx], $this->cell_landmark))
                {
                    $product_row_array = parse_array($table_array[$xx], "<tr", "</tr>");
                    break;
                }
            }
        }
        for($table_row=0; $table_row<count($product_row_array); $table_row++)
        {
            if(stristr($product_row_array[$table_row], $this->cell_landmark))
            {
                $table_cell_array = parse_array($product_row_array[$table_row], "<td", "</td>");
                break;
            }
        }
        for($cell_num=0; $cell_num<count($table_cell_array); $cell_num++)
        {
            if(stristr($table_cell_array[$cell_num], $this->cell_landmark)){
                preg_match($regex,$table_cell_array[$cell_num+1], $return_value );
                break;
            }
        }
        return $return_value;
    }
}
?>
